﻿using System;
using System.Windows.Forms;

namespace PicasaWebAlbumsDownloader
{
    public class Progress : IDisposable
    {
        private readonly ISupportProgress control;
        private readonly bool disable;

        public Progress(ISupportProgress control, bool disable = true)
        {
            this.control = control;
            this.disable = disable;
            if (disable)
            {
                control.Enabled = false;
            }
            control.WaitCursor = true;
            control.ProgressState = ProgressState.Min;
            Application.DoEvents();
        }

        public void Dispose()
        {
            if (disable)
            {
                control.Enabled = true;
            }
            control.WaitCursor = false;
            control.ProgressState = ProgressState.Max;
            Application.DoEvents();
        }
    }
}